import request from '@/amtf/utils/request'
import { useRoute } from 'vue-router';
// import { use当前url } from '@/amtf/hooks/hook';
import use路由 from '@/amtf/hooks/use路由';
// export default API

export default function (url = '') {
    if (!url) {
        url = use路由().api路径.value
    }

    const 增 = (data) => {
        return request({
            url,
            method: 'post',
            data
        });
    }
    const 删 = (params) => {
        return request({
            url,
            method: 'delete',
            params
        });
    }
    const 查 = (params) => {
        return request({
            url,
            method: 'get',
            params
        });
    }

    const 查字段候选值集 = (params) => {
        return request({
            url: url + "/查字段候选值集",
            method: 'get',
            params
        });
    }

    const 查外键关联记录集 = (params) => {
        return request({
            url: url + "/查外键关联记录集",
            method: 'get',
            params
        });
    }

    const 改 = (data) => {
        console.log(`改 data 👉`, data)
        return request({
            url,
            method: 'put',
            data
        })
    }

    return { 增, 删, 改, 查, 查字段候选值集, 查外键关联记录集 }
}